package cn.edu.sasu;

import cn.edu.sasu.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import cn.edu.sasu.adapter.newsdetail.newsmore.NewsMoreAdapter;
import cn.edu.sasu.http.HttpUrl;

/**
 * 当用户点击导航上面的更多新闻的时候，处理的Activity，显示剩下的新闻列表
 * <p/>
 * &nbsp;&nbsp;&nbsp;&nbsp;加载新闻条目到ListView中
 * 
 * @author yubaolinfish
 * 
 */
public class NewsMoreActivity extends Activity {

	private ListView listView = null;
	private String array[] = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.news_more);

		array = getResources().getStringArray(R.array.more);// 取得到value文件夹下定义的数组
		listView = (ListView) findViewById(R.id.listView_news_more);
		listView.setAdapter(new NewsMoreAdapter(array, this));// 将创建好的ListView适配器赋给ListView中

		listView.setOnItemClickListener(listener);
	}

	private OnItemClickListener listener = new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> parent, View view, int position,
				long id) {
			Intent intent = new Intent(NewsMoreActivity.this, NewsMoreItemActivity.class);
			Bundle bundle = new Bundle();
			switch (position) {// 条目是从0开始标号的
			case 0:// 点击“综合服务”
				bundle.putString("more_news_list_url", HttpUrl.URL_NEWS_INTEGRATEDSERVICE);
				break;
			case 1:// 点击“学术动态”
				bundle.putString("more_news_list_url", HttpUrl.URL_NEWS_ACADEMICTRENDS);
				break;
			case 2:// 点击“创优争先”
				bundle.putString("more_news_list_url", HttpUrl.URL_NEWS_BEFOREEXCELLENT);
				break;
			case 3:// 点击“中国梦”
				bundle.putString("more_news_list_url", HttpUrl.URL_NEWS_CHINADREAM);
				break;
			case 4:// 点击“群总路线”
				bundle.putString("more_news_list_url", HttpUrl.URL_NEWS_MASSLINE);
				break;
			}

			bundle.putString("text", array[position]);
			intent.putExtras(bundle);
			NewsMoreActivity.this.startActivity(intent);

		}
	};

}
